<?php

namespace App\Http\Controllers;

use App\Weibo;

class WeiboController extends Controller
{

    public function __construct()
    {
        $this->middleware(['auth', 'admin'], ['except' => ['index', 'images', 'parseurl', 'weiboImages']]);
    }

    public function index() {
        $weibos = Weibo::orderBy('created_at','desc')->paginate(25);
        return view('weibo.index',compact('weibos'));
    }

    public function weiboImages() {
        //header('Access-Control-Allow-Origin: *');
        $weibos = Weibo::where('images','like','%http%')->where('type','=','favorate')->orderBy('created_at','desc')->paginate(5);
        return view('weibo.images',compact('weibos'));
    }

    public function isTrash(Weibo $weibo){
        $weibo->update(['type'=>'trash']);
    }

    public function isValue(Weibo $weibo){
        $weibo->update(['type'=>'favorate']);
    }

}
